package org.example.commons.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.converters.string.StringStringConverter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
import java.io.Serializable;

import static org.example.commons.constant.Constants.SIMPLE_DATE_FORMAT;

/**
 * 消息反馈表(SysMessage)实体类
 *
 * @author makejava
 * @since 2020-06-14 21:51:54
 */
@Entity
@DynamicUpdate
@Data
@NoArgsConstructor
@AllArgsConstructor
@ColumnWidth(20)
public class SysMessage implements Serializable {
    private static final long serialVersionUID = -40692532121851645L;
    /**
    * 消息ID
    */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ExcelProperty("消息编号")
    private Long messageId;
    /**
    * 接收人ID
    */
    @ExcelIgnore
    private Long userId;
    /**
    * 接收人名字
    */
    @ExcelProperty("住户")
    private String userName;
    /**
    * 接收方（0发送到后台 1发送给用户 2都发送）
    */
    @ExcelIgnore
    private String sendTo;
    /**
    * 是否已读（0未读 1已读）
    */
    @ExcelIgnore
    private String status;
    /**
    * 消息标题
    */
    @ExcelProperty("消息标题")
    private String title;
    /**
    * 反馈内容
    */
    @ExcelProperty("反馈内容")
    private String content;
    /**
    * 创建时间
    */
    @ExcelProperty(value = "记录时间",converter = StringStringConverter.class)
    private Date createTime;




    public String getCreateTime() {
        if (createTime!=null)
            return SIMPLE_DATE_FORMAT.format(createTime);
        else
            return "";
    }


}